package com.example.summary.leetcode;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by wzn on 2019/7/29.
 */
public class LeetCode70 {

    public Map<Integer, Integer> map = new HashMap<>();

    public int climbStairs(int n) {
        Integer integer = map.get(n);
        if (null != integer) {
            return integer;
        }

        if (n == 1) {
            return 1;
        }

        if (n == 2) {
            return 2;
        }

        int result = climbStairs(n - 1) + climbStairs(n - 2);
        map.put(n, result);
        return result;
    }
}
